home *** CD-ROM | disk | FTP | other *** search
/ SCI Games E3 2005 Press Kit (USA) / SCI Games E3 2005 Press Kit (USA).bin / runme_mac.swf / scripts / __Packages / mx / controls / streamingmedia / LoadBar.as < prev    next >
Text File  |  2005-05-05  |  3KB  |  146 lines

  1. class mx.controls.streamingmedia.LoadBar extends MovieClip
  2. {
  3.    function LoadBar()
  4.    {
  5.       super();
  6.       this.init();
  7.    }
  8.    function init()
  9.    {
  10.       this._controller = this._parent;
  11.       this.draw();
  12.    }
  13.    function isVertical()
  14.    {
  15.       return !this._controller.__get__horizontal();
  16.    }
  17.    function getCompletionPercentage()
  18.    {
  19.       var _loc2_ = undefined;
  20.       if(this.isVertical())
  21.       {
  22.          _loc2_ = this.yToPercent(this._fill._height);
  23.       }
  24.       else
  25.       {
  26.          _loc2_ = this.xToPercent(this._fill._width);
  27.       }
  28.       return _loc2_;
  29.    }
  30.    function setCompletionPercentage(aPercentage)
  31.    {
  32.       aPercentage = Math.floor(aPercentage);
  33.       if(aPercentage < 0)
  34.       {
  35.          aPercentage = 0;
  36.       }
  37.       else if(aPercentage > 100)
  38.       {
  39.          aPercentage = 100;
  40.       }
  41.       if(this.isVertical())
  42.       {
  43.          this._fill._height = this.percentToY(aPercentage);
  44.          this._fill._y = this.getActualHeight() - this._fill._height - 1;
  45.       }
  46.       else
  47.       {
  48.          this._fill._width = this.percentToX(aPercentage);
  49.       }
  50.    }
  51.    function draw(size)
  52.    {
  53.       var _loc3_ = this.getCompletionPercentage();
  54.       if(this.isVertical())
  55.       {
  56.          if(size == null)
  57.          {
  58.             size = this.getHeight();
  59.          }
  60.          this._y = 8;
  61.          this._border._height = size;
  62.          this._background._height = size - 2;
  63.       }
  64.       else
  65.       {
  66.          if(size == null)
  67.          {
  68.             size = this.getWidth();
  69.          }
  70.          this._x = 8;
  71.          this._border._width = size;
  72.          this._background._width = size - 2;
  73.       }
  74.       this.setCompletionPercentage(_loc3_);
  75.    }
  76.    function getWidth()
  77.    {
  78.       var _loc2_ = undefined;
  79.       if(this.isVertical())
  80.       {
  81.          _loc2_ = 3;
  82.       }
  83.       else
  84.       {
  85.          _loc2_ = this._controller.__get__width() - 16;
  86.       }
  87.       return _loc2_;
  88.    }
  89.    function getHeight()
  90.    {
  91.       var _loc2_ = undefined;
  92.       if(this.isVertical())
  93.       {
  94.          if(this._controller.__get__expanded())
  95.          {
  96.             _loc2_ = this.getOpenHeight();
  97.          }
  98.          else
  99.          {
  100.             _loc2_ = this.getClosedHeight();
  101.          }
  102.       }
  103.       else
  104.       {
  105.          _loc2_ = 3;
  106.       }
  107.       return _loc2_;
  108.    }
  109.    function getActualHeight()
  110.    {
  111.       return this._border._height;
  112.    }
  113.    function getActualWidth()
  114.    {
  115.       return this._border._width;
  116.    }
  117.    function getOpenHeight()
  118.    {
  119.       return this._controller.__get__height() - 90;
  120.    }
  121.    function getClosedHeight()
  122.    {
  123.       return this._controller.__get__height() - 16;
  124.    }
  125.    function xToPercent(x)
  126.    {
  127.       var _loc2_ = 100 * x / (this.getActualWidth() - 2);
  128.       return _loc2_;
  129.    }
  130.    function percentToX(percent)
  131.    {
  132.       var _loc2_ = (this.getWidth() - 2) * (percent / 100);
  133.       return _loc2_;
  134.    }
  135.    function yToPercent(y)
  136.    {
  137.       var _loc2_ = 100 * (y - 0) / (this.getActualHeight() - 2);
  138.       return _loc2_;
  139.    }
  140.    function percentToY(percent)
  141.    {
  142.       var _loc2_ = (this.getActualHeight() - 2) * (percent / 100);
  143.       return _loc2_;
  144.    }
  145. }
  146.